﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Models
{
    public class GameRandom
    {
        private static GameRandom instance;

        private Random rand;

        private GameRandom()
        {
            rand = new Random();
        }

        static public GameRandom getInstance()
        {
            if (instance == null)
            {
                instance = new GameRandom();
            } 
            return instance;
        }

        public int getInteger(int min, int max)
        {
            if (max < min)
            {
                throw new ArgumentOutOfRangeException("Minimum er mindre end maximum!");
            }
            return rand.Next(max - min + 1) + min;
        }

        public float getSingle(float min, float max)
        {
            if (max < min)
            {
                throw new ArgumentOutOfRangeException("Minimum er mindre end maximum!");
            }
            float range = max - min;
            float ran = (float)rand.NextDouble();

            return range * ran + min;
        }
    }
}
